﻿<phone:PhoneApplicationPage xmlns:my="clr-namespace:Microsoft.Advertising.Mobile.UI;assembly=Microsoft.Advertising.Mobile.UI"  
    x:Class="Groovy_IM.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="728" 
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="PortraitOrLandscape"  Orientation="Portrait"
    shell:SystemTray.IsVisible="False" OrientationChanged="PhoneApplicationPage_OrientationChanged">

    <Grid x:Name="LayoutRoot" Background="Transparent">        
        <controls:Pivot Title="Groovy IM" x:Name="pivSwitch" SelectionChanged="Pivot_SelectionChanged">
            <!--"Contacts" Item One-->
            <controls:PivotItem Header="Contacts">
                <Grid>
                    <toolkit:LongListSelector x:Name="buddyList" DisplayAllGroups="True">
                        <toolkit:LongListSelector.GroupHeaderTemplate>
                            <DataTemplate>
                                <Border Background="{StaticResource PhoneAccentBrush}" BorderThickness="3" Margin="0,0,0,0" Height="60" Width="455" Tag="{Binding}">
                                    <TextBlock Tag="{Binding}" Text="{Binding Key}" FontSize="{StaticResource PhoneFontSizeLarge}" Foreground="White" Margin="20,0,0,0" Tap="GroupCollapse_Tap"/>
                                </Border>
                            </DataTemplate>
                        </toolkit:LongListSelector.GroupHeaderTemplate>

                        <toolkit:LongListSelector.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Visibility="{Binding CollapseVisibility}" Tag="{Binding}" Margin="0,0,0,0" Tap="BuddylistItem_Tap">
                                    <Image Source="{Binding BuddyIcon}" Width="64" Height="64" HorizontalAlignment="Left" />
                                    <Image Source="{Binding BuddyProtocol}" Width="24" Height="24" HorizontalAlignment="Left" Margin="68,-90,0,0" />
                                    <TextBlock Text="{Binding Screenname}" FontSize="24" Margin="104,-64,0,64" TextWrapping="NoWrap" />
                                    <Image Source="{Binding UserStatus}" Width="16" Height="16" HorizontalAlignment="Left" Margin="72,-94,0,0" />
                                    <TextBlock Text="{Binding BuddyStatus}" FontSize="16" Margin="104,-60,0,0" TextWrapping="Wrap" />
                                </StackPanel>
                            </DataTemplate>
                        </toolkit:LongListSelector.ItemTemplate>
                    </toolkit:LongListSelector>
                    <TextBlock Text="No Contacts Available" HorizontalAlignment="Center" Margin="8,0,0,0" x:Name="noGroupsTextBlock" Visibility="Visible" Style="{StaticResource PhoneTextTitle2Style}"/>
                </Grid>
            </controls:PivotItem>

            <!--"Chats" Item Two-->
            <controls:PivotItem Header="Chats">
                <Grid>
                    <toolkit:LongListSelector x:Name="chatList" DisplayAllGroups="True">
                        <toolkit:LongListSelector.GroupHeaderTemplate>
                            <DataTemplate>
                                <Border Background="{StaticResource PhoneAccentBrush}" BorderThickness="3" Margin="0,0,0,0" Height="60" Width="455">
                                    <TextBlock Tag="{Binding}" Text="{Binding Key}" FontSize="{StaticResource PhoneFontSizeLarge}" Foreground="White" Margin="20,0,0,0" Tap="ChatCollapse_Tap"/>
                                </Border>
                            </DataTemplate>
                        </toolkit:LongListSelector.GroupHeaderTemplate>

                        <toolkit:LongListSelector.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Visibility="{Binding CollapseVisibility}" Tag="{Binding}" Margin="0,0,0,0">
                                    <Image Source="{Binding ChatIcon}" Width="64" Height="64" HorizontalAlignment="Left" Tag="{Binding Tag}" Tap="TextBlock_Tap"/>
                                    <Image Source="{Binding Protocol}" Width="24" Height="24" HorizontalAlignment="Left" Margin="68,-90,0,0" Tag="{Binding Tag}" Tap="TextBlock_Tap"/>
                                    <TextBlock Text="{Binding Screenname}" FontSize="24" Margin="104,-64,0,64" TextWrapping="NoWrap" Tag="{Binding Tag}" Tap="TextBlock_Tap"/>
                                    <Image Source="{Binding UserStatus}" Width="16" Height="16" HorizontalAlignment="Left" Margin="72,-94,0,0" Tag="{Binding Tag}" Tap="TextBlock_Tap" />
                                    <TextBlock Text="{Binding LastMessage}" FontSize="16" Margin="104,-60,0,0" TextWrapping="Wrap" Tag="{Binding Tag}" Tap="TextBlock_Tap" />
                                </StackPanel>
                            </DataTemplate>
                        </toolkit:LongListSelector.ItemTemplate>
                    </toolkit:LongListSelector>
                    <TextBlock Text="No Chats Available" HorizontalAlignment="Center" Margin="8,0,0,0" x:Name="noChatsTextBlock" Visibility="Visible" Style="{StaticResource PhoneTextTitle2Style}"/>
                </Grid>
            </controls:PivotItem>
            
            <!--"Profile" Item Three-->
            <controls:PivotItem Header="Profile">
                
            </controls:PivotItem>
        </controls:Pivot>
        <my:AdControl AdUnitId="73222" IsAutoRefreshEnabled="True" ApplicationId="0a9ad2b9-7176-4b22-b514-04e2afe06a63" Height="80" HorizontalAlignment="Left" Margin="0,647,0,0" Name="showADs" VerticalAlignment="Top" Width="480" Visibility="Visible" />
    </Grid>

    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton IconUri="/Images/App/AppBar/appbar.feature.account.rest.png" Text="accounts"/>
            <shell:ApplicationBarIconButton IconUri="/Images/App/AppBar/appbar.feature.search.rest.png" Text="search"/>
            <shell:ApplicationBarIconButton IconUri="/Images/App/AppBar/appbar.feature.settings.rest.png" Text="settings"/>            
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Text="help"/>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>
</phone:PhoneApplicationPage>